import { Controller, Get, Inject, Injectable } from '@nestjs/common';
import { AppService } from './app.service';
//import { TypechoContents } from './entities/typecho/TypechoContents';
import { CACHE_MANAGER } from '@nestjs/cache-manager';
// import { InjectRepository } from '@mikro-orm/nestjs';

@Controller()
export class AppController {
  constructor(
    private readonly appService: AppService,
    // @InjectMikroORM('zp')
    // private readonly orm : MikroORM,
    // @InjectEntityManager('zp')
    // private readonly em : EntityManager,
    
    @Inject(CACHE_MANAGER) 
    private cache: Cache
    ) {}

  @Get()
  async getHello(): Promise<string> {

    return ''
    //const content : Object = await this.em.qb(TypechoContents).where({cid:7}).execute('get',true);
    //const text = JSON.stringify(content);

    // const knex = this.em.getKnex();

    // const job_task_ids = this.em.qb(OrderJobEnrolls).distinct().select('job_task_id');
    // const creator_ids = this.em.qb(JobTasks).distinct().select('creator_id').where({id:{'$in': job_task_ids.getKnexQuery()}});
    // const users = await this.em.qb(Users).select('*').where({id:creator_ids.getKnexQuery()}).execute();

    //return JSON.stringify(users);

    // const tasks = await this.em.find(JobTasks,{},{limit: 1});
    // const task = tasks.pop();
    // const objTask =  wrap(task,true).toObject();
    // const jsonTask =  wrap(task,true).toJSON();
    // const pojoTask =  wrap(task,true).toPOJO();

    //return JSON.stringify(jsonTask);
    //return await this.appService.getHello();
  }
}
